<?php
/**
 * Created by PhpStorm.
 * User: yyq
 * Date: 2018/8/22
 * Time: 17:29
 */

namespace Common\Model;


class CategoryModel extends CommonModel
{
    /**
     * @param int $cate_id
     * @return string
     */
    public function getCateOption($cate_id=0) {
        $cate = $this->where(['if_show' => 'yes'])->order('sort asc')->select();
        $options = '';
        foreach ($cate as $k => $v) {
            if($v['cate_id'] == $cate_id) {
                $options .= '<option value="'.$v['cate_id'].'" selected>'.$v['cate_name'].'</option>';
            } else {
                $options .= '<option value="'.$v['cate_id'].'">'.$v['cate_name'].'</option>';
            }
        }
        return $options;
    }
}